<?php
if (session_id() == "") session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include_once "ewcfg8.php" ?>
<?php include_once "ewmysql8.php" ?>
<?php include_once "phpfn8.php" ?>
<?php include_once "transactioninfo.php" ?>
<?php include_once "userinfo.php" ?>
<?php include_once "userfn8.php" ?>
<?php ew_Header(TRUE) ?>
<?php

// Create page object
$transaction_search = new ctransaction_search();
$Page =& $transaction_search;

// Page init
$transaction_search->Page_Init();

// Page main
$transaction_search->Page_Main();
?>
<?php include_once "header.php" ?>
<script type="text/javascript">
<!--

// Create page object
var transaction_search = new ew_Page("transaction_search");

// page properties
transaction_search.PageID = "search"; // page ID
transaction_search.FormID = "ftransactionsearch"; // form ID
var EW_PAGE_ID = transaction_search.PageID; // for backward compatibility

// extend page with validate function for search
transaction_search.ValidateSearch = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (this.ValidateRequired) {
		var infix = "";
		elm = fobj.elements["x" + infix + "_id"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($transaction->id->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_user_id"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($transaction->user_id->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_amount"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($transaction->amount->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_total_item"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($transaction->total_item->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_total_weight"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($transaction->total_weight->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_postage_price"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($transaction->postage_price->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_items_price"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($transaction->items_price->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_shipping_address_id"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($transaction->shipping_address_id->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_paydate"];
		if (elm && !ew_CheckEuroDate(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($transaction->paydate->FldErrMsg()) ?>");

		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj))
			return false;
	}
	for (var i=0; i<fobj.elements.length; i++) {
		var elem = fobj.elements[i];
		if (elem.name.substring(0,2) == "s_" || elem.name.substring(0,3) == "sv_")
			elem.value = "";
	}
	return true;
}

// extend page with Form_CustomValidate function
transaction_search.Form_CustomValidate =  
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
<?php if (EW_CLIENT_VALIDATE) { ?>
transaction_search.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
transaction_search.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</script>
<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-cold-1.css" title="win2k-1">
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
//-->

</script>
<p class="phpmaker ewTitle"><?php echo $Language->Phrase("Search") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $transaction->TableCaption() ?></p>
<p class="phpmaker"><a href="<?php echo $transaction->getReturnUrl() ?>"><?php echo $Language->Phrase("BackToList") ?></a></p>
<?php $transaction_search->ShowPageHeader(); ?>
<?php
$transaction_search->ShowMessage();
?>
<form name="ftransactionsearch" id="ftransactionsearch" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return transaction_search.ValidateSearch(this);">
<p>
<input type="hidden" name="t" id="t" value="transaction">
<input type="hidden" name="a_search" id="a_search" value="S">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
	<tr id="r_id"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->id->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_id" id="z_id" value="="></td>
		<td<?php echo $transaction->id->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<input type="text" name="x_id" id="x_id" value="<?php echo $transaction->id->EditValue ?>"<?php echo $transaction->id->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_order_no"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->order_no->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_order_no" id="z_order_no" value="="></td>
		<td<?php echo $transaction->order_no->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<input type="text" name="x_order_no" id="x_order_no" size="70" maxlength="255" value="<?php echo $transaction->order_no->EditValue ?>"<?php echo $transaction->order_no->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_user_id"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->user_id->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_user_id" id="z_user_id" value="="></td>
		<td<?php echo $transaction->user_id->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<span id="as_x_user_id" style="white-space: nowrap; z-index: 8970">
	<input type="text" name="sv_x_user_id" id="sv_x_user_id" value="<?php echo $transaction->user_id->EditValue ?>" size="70"<?php echo $transaction->user_id->EditAttributes() ?>>&nbsp;<span id="em_x_user_id" class="ewMessage" style="display: none"><?php echo str_replace("%f", "phpimages/", $Language->Phrase("UnmatchedValue")) ?></span>
	<div id="sc_x_user_id" style="z-index: 8970"></div>
</span>
<input type="hidden" name="x_user_id" id="x_user_id" value="<?php echo $transaction->user_id->AdvancedSearch->SearchValue ?>">
<?php
$sSqlWrk = "SELECT `id`, `username`, `name`, `no_ahli` FROM `user`";
$sWhereWrk = "`username`  LIKE '{query_value}%'";
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " LIMIT " . EW_AUTO_SUGGEST_MAX_ENTRIES;
	$sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
?>
<input type="hidden" name="s_x_user_id" id="s_x_user_id" value="<?php echo $sSqlWrk ?>">
<script type="text/javascript">
<!--
var oas_x_user_id = new ew_AutoSuggest("sv_x_user_id", "sc_x_user_id", "s_x_user_id", "em_x_user_id", "x_user_id", "", false, EW_AUTO_SUGGEST_MAX_ENTRIES);
oas_x_user_id.formatResult = function(ar) {	
	var df1 = ar[1];
	var df2 = ar[2];
	if (df2 != "")
		df1 += EW_FIELD_SEP + df2;
	var df3 = ar[3];
	if (df3 != "")
		df1 += EW_FIELD_SEP + df3;
	return df1;
};
oas_x_user_id.ac.typeAhead = false;

//-->
</script>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_amount"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->amount->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_amount" id="z_amount" value="="></td>
		<td<?php echo $transaction->amount->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<input type="text" name="x_amount" id="x_amount" size="30" maxlength="255" value="<?php echo $transaction->amount->EditValue ?>"<?php echo $transaction->amount->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_status_payment"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->status_payment->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_status_payment" id="z_status_payment" value="LIKE"></td>
		<td<?php echo $transaction->status_payment->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<input type="text" name="x_status_payment" id="x_status_payment" size="30" maxlength="255" value="<?php echo $transaction->status_payment->EditValue ?>"<?php echo $transaction->status_payment->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_status_transaction"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->status_transaction->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_status_transaction" id="z_status_transaction" value="LIKE"></td>
		<td<?php echo $transaction->status_transaction->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<div id="tp_x_status_transaction" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME ?>"><label><input type="radio" name="x_status_transaction" id="x_status_transaction" value="{value}"<?php echo $transaction->status_transaction->EditAttributes() ?>></label></div>
<div id="dsl_x_status_transaction" data-repeatcolumn="5" class="ewItemList">
<?php
$arwrk = $transaction->status_transaction->EditValue;
if (is_array($arwrk)) {
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($transaction->status_transaction->AdvancedSearch->SearchValue) == strval($arwrk[$rowcntwrk][0])) ? " checked=\"checked\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="radio" name="x_status_transaction" id="x_status_transaction" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $transaction->status_transaction->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</div>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_total_item"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->total_item->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_total_item" id="z_total_item" value="="></td>
		<td<?php echo $transaction->total_item->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<input type="text" name="x_total_item" id="x_total_item" size="30" maxlength="255" value="<?php echo $transaction->total_item->EditValue ?>"<?php echo $transaction->total_item->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_total_weight"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->total_weight->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_total_weight" id="z_total_weight" value="="></td>
		<td<?php echo $transaction->total_weight->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<input type="text" name="x_total_weight" id="x_total_weight" size="30" value="<?php echo $transaction->total_weight->EditValue ?>"<?php echo $transaction->total_weight->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_postage_price"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->postage_price->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_postage_price" id="z_postage_price" value="="></td>
		<td<?php echo $transaction->postage_price->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<input type="text" name="x_postage_price" id="x_postage_price" size="30" value="<?php echo $transaction->postage_price->EditValue ?>"<?php echo $transaction->postage_price->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_items_price"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->items_price->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_items_price" id="z_items_price" value="="></td>
		<td<?php echo $transaction->items_price->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<input type="text" name="x_items_price" id="x_items_price" size="30" value="<?php echo $transaction->items_price->EditValue ?>"<?php echo $transaction->items_price->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_type_price"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->type_price->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_type_price" id="z_type_price" value="="></td>
		<td<?php echo $transaction->type_price->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<div id="tp_x_type_price" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME ?>"><label><input type="radio" name="x_type_price" id="x_type_price" value="{value}"<?php echo $transaction->type_price->EditAttributes() ?>></label></div>
<div id="dsl_x_type_price" data-repeatcolumn="5" class="ewItemList">
<?php
$arwrk = $transaction->type_price->EditValue;
if (is_array($arwrk)) {
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($transaction->type_price->AdvancedSearch->SearchValue) == strval($arwrk[$rowcntwrk][0])) ? " checked=\"checked\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="radio" name="x_type_price" id="x_type_price" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $transaction->type_price->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</div>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_shipping_address_id"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->shipping_address_id->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_shipping_address_id" id="z_shipping_address_id" value="="></td>
		<td<?php echo $transaction->shipping_address_id->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<span id="as_x_shipping_address_id" style="white-space: nowrap; z-index: 8880">
	<input type="text" name="sv_x_shipping_address_id" id="sv_x_shipping_address_id" value="<?php echo $transaction->shipping_address_id->EditValue ?>" size="30"<?php echo $transaction->shipping_address_id->EditAttributes() ?>>&nbsp;<span id="em_x_shipping_address_id" class="ewMessage" style="display: none"><?php echo str_replace("%f", "phpimages/", $Language->Phrase("UnmatchedValue")) ?></span>
	<div id="sc_x_shipping_address_id" style="z-index: 8880"></div>
</span>
<input type="hidden" name="x_shipping_address_id" id="x_shipping_address_id" value="<?php echo $transaction->shipping_address_id->AdvancedSearch->SearchValue ?>">
<?php
$sSqlWrk = "SELECT `id`, `address`, `poskod`, `city` FROM `address`";
$sWhereWrk = "`address`  LIKE '{query_value}%'";
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " LIMIT " . EW_AUTO_SUGGEST_MAX_ENTRIES;
	$sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
?>
<input type="hidden" name="s_x_shipping_address_id" id="s_x_shipping_address_id" value="<?php echo $sSqlWrk ?>">
<script type="text/javascript">
<!--
var oas_x_shipping_address_id = new ew_AutoSuggest("sv_x_shipping_address_id", "sc_x_shipping_address_id", "s_x_shipping_address_id", "em_x_shipping_address_id", "x_shipping_address_id", "", false, EW_AUTO_SUGGEST_MAX_ENTRIES);
oas_x_shipping_address_id.formatResult = function(ar) {	
	var df1 = ar[1];
	var df2 = ar[2];
	if (df2 != "")
		df1 += EW_FIELD_SEP + df2;
	var df3 = ar[3];
	if (df3 != "")
		df1 += EW_FIELD_SEP + df3;
	return df1;
};
oas_x_shipping_address_id.ac.typeAhead = false;

//-->
</script>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_appcode"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->appcode->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_appcode" id="z_appcode" value="LIKE"></td>
		<td<?php echo $transaction->appcode->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<input type="text" name="x_appcode" id="x_appcode" size="70" maxlength="255" value="<?php echo $transaction->appcode->EditValue ?>"<?php echo $transaction->appcode->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_tranid"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->tranid->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_tranid" id="z_tranid" value="LIKE"></td>
		<td<?php echo $transaction->tranid->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<input type="text" name="x_tranid" id="x_tranid" size="70" maxlength="255" value="<?php echo $transaction->tranid->EditValue ?>"<?php echo $transaction->tranid->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_status_nbepay"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->status_nbepay->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_status_nbepay" id="z_status_nbepay" value="LIKE"></td>
		<td<?php echo $transaction->status_nbepay->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<input type="text" name="x_status_nbepay" id="x_status_nbepay" size="70" maxlength="255" value="<?php echo $transaction->status_nbepay->EditValue ?>"<?php echo $transaction->status_nbepay->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_paydate"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->paydate->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("BETWEEN") ?><input type="hidden" name="z_paydate" id="z_paydate" value="BETWEEN"></td>
		<td<?php echo $transaction->paydate->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<input type="text" name="x_paydate" id="x_paydate" size="70" value="<?php echo $transaction->paydate->EditValue ?>"<?php echo $transaction->paydate->EditAttributes() ?>>
&nbsp;<img src="phpimages/calendar.png" id="cal_x_paydate" name="cal_x_paydate" alt="<?php echo $Language->Phrase("PickDate") ?>" title="<?php echo $Language->Phrase("PickDate") ?>" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup({
	inputField: "x_paydate", // input field id
	ifFormat: "%d/%m/%Y", // date format
	button: "cal_x_paydate" // button id
});
</script>
</span>
				<span class="ewSearchCond" id="btw1_paydate" name="btw1_paydate">&nbsp;<?php echo $Language->Phrase("AND") ?>&nbsp;</span>
				<span class="phpmaker" id="btw1_paydate" name="btw1_paydate">
<input type="text" name="y_paydate" id="y_paydate" size="70" value="<?php echo $transaction->paydate->EditValue2 ?>"<?php echo $transaction->paydate->EditAttributes() ?>>
&nbsp;<img src="phpimages/calendar.png" id="cal_y_paydate" name="cal_y_paydate" alt="<?php echo $Language->Phrase("PickDate") ?>" title="<?php echo $Language->Phrase("PickDate") ?>" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup({
	inputField: "y_paydate", // input field id
	ifFormat: "%d/%m/%Y", // date format
	button: "cal_y_paydate" // button id
});
</script>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_isInvalid"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->isInvalid->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("=") ?><input type="hidden" name="z_isInvalid" id="z_isInvalid" value="="></td>
		<td<?php echo $transaction->isInvalid->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<select id="x_isInvalid" name="x_isInvalid"<?php echo $transaction->isInvalid->EditAttributes() ?>>
<?php
if (is_array($transaction->isInvalid->EditValue)) {
	$arwrk = $transaction->isInvalid->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($transaction->isInvalid->AdvancedSearch->SearchValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_remarks"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->remarks->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_remarks" id="z_remarks" value="LIKE"></td>
		<td<?php echo $transaction->remarks->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<textarea name="x_remarks" id="x_remarks" cols="70" rows="6"<?php echo $transaction->remarks->EditAttributes() ?>><?php echo $transaction->remarks->EditValue ?></textarea>
</span>
			</div>
		</td>
	</tr>
	<tr id="r_consignment_no"<?php echo $transaction->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $transaction->consignment_no->FldCaption() ?></td>
		<td class="ewSearchOprCell"><?php echo $Language->Phrase("LIKE") ?><input type="hidden" name="z_consignment_no" id="z_consignment_no" value="LIKE"></td>
		<td<?php echo $transaction->consignment_no->CellAttributes() ?>>
			<div style="white-space: nowrap;">
				<span class="phpmaker">
<input type="text" name="x_consignment_no" id="x_consignment_no" size="70" maxlength="255" value="<?php echo $transaction->consignment_no->EditValue ?>"<?php echo $transaction->consignment_no->EditAttributes() ?>>
</span>
			</div>
		</td>
	</tr>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="Action" id="Action" value="<?php echo ew_BtnCaption($Language->Phrase("Search")) ?>">
<input type="button" name="Reset" id="Reset" value="<?php echo ew_BtnCaption($Language->Phrase("Reset")) ?>" onclick="ew_ClearForm(this.form);">
</form>
<?php
$transaction_search->ShowPageFooter();
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
?>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php include_once "footer.php" ?>
<?php
$transaction_search->Page_Terminate();
?>
<?php

//
// Page class
//
class ctransaction_search {

	// Page ID
	var $PageID = 'search';

	// Table name
	var $TableName = 'transaction';

	// Page object name
	var $PageObjName = 'transaction_search';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $transaction;
		if ($transaction->UseTokenInUrl) $PageUrl .= "t=" . $transaction->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_MESSAGE], $v);
	}

	function getFailureMessage() {
		return @$_SESSION[EW_SESSION_FAILURE_MESSAGE];
	}

	function setFailureMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_FAILURE_MESSAGE], $v);
	}

	function getSuccessMessage() {
		return @$_SESSION[EW_SESSION_SUCCESS_MESSAGE];
	}

	function setSuccessMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_SUCCESS_MESSAGE], $v);
	}

	// Show message
	function ShowMessage() {
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage, "");
		if ($sMessage <> "") { // Message in Session, display
			echo "<p class=\"ewMessage\">" . $sMessage . "</p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}

		// Success message
		$sSuccessMessage = $this->getSuccessMessage();
		$this->Message_Showing($sSuccessMessage, "success");
		if ($sSuccessMessage <> "") { // Message in Session, display
			echo "<p class=\"ewSuccessMessage\">" . $sSuccessMessage . "</p>";
			$_SESSION[EW_SESSION_SUCCESS_MESSAGE] = ""; // Clear message in Session
		}

		// Failure message
		$sErrorMessage = $this->getFailureMessage();
		$this->Message_Showing($sErrorMessage, "failure");
		if ($sErrorMessage <> "") { // Message in Session, display
			echo "<p class=\"ewErrorMessage\">" . $sErrorMessage . "</p>";
			$_SESSION[EW_SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session
		}
	}
	var $PageHeader;
	var $PageFooter;

	// Show Page Header
	function ShowPageHeader() {
		$sHeader = $this->PageHeader;
		$this->Page_DataRendering($sHeader);
		if ($sHeader <> "") { // Header exists, display
			echo "<p class=\"phpmaker\">" . $sHeader . "</p>";
		}
	}

	// Show Page Footer
	function ShowPageFooter() {
		$sFooter = $this->PageFooter;
		$this->Page_DataRendered($sFooter);
		if ($sFooter <> "") { // Fotoer exists, display
			echo "<p class=\"phpmaker\">" . $sFooter . "</p>";
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm, $transaction;
		if ($transaction->UseTokenInUrl) {
			if ($objForm)
				return ($transaction->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($transaction->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function ctransaction_search() {
		global $conn, $Language;

		// Language object
		if (!isset($Language)) $Language = new cLanguage();

		// Table object (transaction)
		if (!isset($GLOBALS["transaction"])) {
			$GLOBALS["transaction"] = new ctransaction();
			$GLOBALS["Table"] =& $GLOBALS["transaction"];
		}

		// Table object (user)
		if (!isset($GLOBALS['user'])) $GLOBALS['user'] = new cuser();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'search', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'transaction', TRUE);

		// Start timer
		if (!isset($GLOBALS["gTimer"])) $GLOBALS["gTimer"] = new cTimer();

		// Open connection
		if (!isset($conn)) $conn = ew_Connect();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
		global $transaction;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}

		// Create form object
		$objForm = new cFormObj();

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();
		$this->Page_Redirecting($url);

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}

	//
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsSearchError, $transaction;
		if ($this->IsPageRequest()) { // Validate request

			// Get action
			$transaction->CurrentAction = $objForm->GetValue("a_search");
			switch ($transaction->CurrentAction) {
				case "S": // Get search criteria

					// Build search string for advanced search, remove blank field
					$this->LoadSearchValues(); // Get search values
					if ($this->ValidateSearch()) {
						$sSrchStr = $this->BuildAdvancedSearch();
					} else {
						$sSrchStr = "";
						$this->setFailureMessage($gsSearchError);
					}
					if ($sSrchStr <> "") {
						$sSrchStr = $transaction->UrlParm($sSrchStr);
						$this->Page_Terminate("transactionlist.php" . "?" . $sSrchStr); // Go to list page
					}
			}
		}

		// Restore search settings from Session
		if ($gsSearchError == "")
			$this->LoadAdvancedSearch();

		// Render row for search
		$transaction->RowType = EW_ROWTYPE_SEARCH;
		$transaction->ResetAttrs();
		$this->RenderRow();
	}

// Build advanced search
function BuildAdvancedSearch() {
	global $transaction;
	$sSrchUrl = "";
	$this->BuildSearchUrl($sSrchUrl, $transaction->id); // id
	$this->BuildSearchUrl($sSrchUrl, $transaction->order_no); // order_no
	$this->BuildSearchUrl($sSrchUrl, $transaction->user_id); // user_id
	$this->BuildSearchUrl($sSrchUrl, $transaction->amount); // amount
	$this->BuildSearchUrl($sSrchUrl, $transaction->status_payment); // status_payment
	$this->BuildSearchUrl($sSrchUrl, $transaction->status_transaction); // status_transaction
	$this->BuildSearchUrl($sSrchUrl, $transaction->total_item); // total_item
	$this->BuildSearchUrl($sSrchUrl, $transaction->total_weight); // total_weight
	$this->BuildSearchUrl($sSrchUrl, $transaction->postage_price); // postage_price
	$this->BuildSearchUrl($sSrchUrl, $transaction->items_price); // items_price
	$this->BuildSearchUrl($sSrchUrl, $transaction->type_price); // type_price
	$this->BuildSearchUrl($sSrchUrl, $transaction->shipping_address_id); // shipping_address_id
	$this->BuildSearchUrl($sSrchUrl, $transaction->appcode); // appcode
	$this->BuildSearchUrl($sSrchUrl, $transaction->tranid); // tranid
	$this->BuildSearchUrl($sSrchUrl, $transaction->status_nbepay); // status_nbepay
	$this->BuildSearchUrl($sSrchUrl, $transaction->paydate); // paydate
	$this->BuildSearchUrl($sSrchUrl, $transaction->isInvalid); // isInvalid
	$this->BuildSearchUrl($sSrchUrl, $transaction->remarks); // remarks
	$this->BuildSearchUrl($sSrchUrl, $transaction->consignment_no); // consignment_no
	return $sSrchUrl;
}

// Build search URL
function BuildSearchUrl(&$Url, &$Fld) {
	global $objForm;
	$sWrk = "";
	$FldParm = substr($Fld->FldVar, 2);
	$FldVal = $objForm->GetValue("x_$FldParm");
	$FldOpr = $objForm->GetValue("z_$FldParm");
	$FldCond = $objForm->GetValue("v_$FldParm");
	$FldVal2 = $objForm->GetValue("y_$FldParm");
	$FldOpr2 = $objForm->GetValue("w_$FldParm");
	$FldVal = ew_StripSlashes($FldVal);
	if (is_array($FldVal)) $FldVal = implode(",", $FldVal);
	$FldVal2 = ew_StripSlashes($FldVal2);
	if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2);
	$FldOpr = strtoupper(trim($FldOpr));
	$lFldDataType = ($Fld->FldIsVirtual) ? EW_DATATYPE_STRING : $Fld->FldDataType;
	if ($FldOpr == "BETWEEN") {
		$IsValidValue = ($lFldDataType <> EW_DATATYPE_NUMBER) ||
			($lFldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal) && is_numeric($FldVal2));
		if ($FldVal <> "" && $FldVal2 <> "" && $IsValidValue) {
			$sWrk = "x_" . $FldParm . "=" . urlencode($FldVal) .
				"&y_" . $FldParm . "=" . urlencode($FldVal2) .
				"&z_" . $FldParm . "=" . urlencode($FldOpr);
		}
	} elseif ($FldOpr == "IS NULL" || $FldOpr == "IS NOT NULL") {
		$sWrk = "x_" . $FldParm . "=" . urlencode($FldVal) .
			"&z_" . $FldParm . "=" . urlencode($FldOpr);
	} else {
		$IsValidValue = ($lFldDataType <> EW_DATATYPE_NUMBER) ||
			($lFldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal));
		if ($FldVal <> "" && $IsValidValue && ew_IsValidOpr($FldOpr, $lFldDataType)) {

			//$FldVal = $this->ConvertSearchValue($Fld, $FldVal);
			$sWrk = "x_" . $FldParm . "=" . urlencode($FldVal) .
				"&z_" . $FldParm . "=" . urlencode($FldOpr);
		}
		$IsValidValue = ($lFldDataType <> EW_DATATYPE_NUMBER) ||
			($lFldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal2));
		if ($FldVal2 <> "" && $IsValidValue && ew_IsValidOpr($FldOpr2, $lFldDataType)) {

			//$FldVal2 = $this->ConvertSearchValue($Fld, $FldVal2);
			if ($sWrk <> "") $sWrk .= "&v_" . $FldParm . "=" . urlencode($FldCond) . "&";
			$sWrk .= "&y_" . $FldParm . "=" . urlencode($FldVal2) .
				"&w_" . $FldParm . "=" . urlencode($FldOpr2);
		}
	}
	if ($sWrk <> "") {
		if ($Url <> "") $Url .= "&";
		$Url .= $sWrk;
	}
}

// Convert search value for date
function ConvertSearchValue(&$Fld, $FldVal) {
	$Value = $FldVal;
	if ($Fld->FldDataType == EW_DATATYPE_DATE && $FldVal <> "")
		$Value = ew_UnFormatDateTime($FldVal, $Fld->FldDateTimeFormat);
	return $Value;
}

	//  Load search values for validation
	function LoadSearchValues() {
		global $objForm, $transaction;

		// Load search values
		// id

		$transaction->id->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_id"));
		$transaction->id->AdvancedSearch->SearchOperator = $objForm->GetValue("z_id");

		// order_no
		$transaction->order_no->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_order_no"));
		$transaction->order_no->AdvancedSearch->SearchOperator = $objForm->GetValue("z_order_no");

		// user_id
		$transaction->user_id->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_user_id"));
		$transaction->user_id->AdvancedSearch->SearchOperator = $objForm->GetValue("z_user_id");

		// amount
		$transaction->amount->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_amount"));
		$transaction->amount->AdvancedSearch->SearchOperator = $objForm->GetValue("z_amount");

		// status_payment
		$transaction->status_payment->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_status_payment"));
		$transaction->status_payment->AdvancedSearch->SearchOperator = $objForm->GetValue("z_status_payment");

		// status_transaction
		$transaction->status_transaction->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_status_transaction"));
		$transaction->status_transaction->AdvancedSearch->SearchOperator = $objForm->GetValue("z_status_transaction");

		// total_item
		$transaction->total_item->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_total_item"));
		$transaction->total_item->AdvancedSearch->SearchOperator = $objForm->GetValue("z_total_item");

		// total_weight
		$transaction->total_weight->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_total_weight"));
		$transaction->total_weight->AdvancedSearch->SearchOperator = $objForm->GetValue("z_total_weight");

		// postage_price
		$transaction->postage_price->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_postage_price"));
		$transaction->postage_price->AdvancedSearch->SearchOperator = $objForm->GetValue("z_postage_price");

		// items_price
		$transaction->items_price->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_items_price"));
		$transaction->items_price->AdvancedSearch->SearchOperator = $objForm->GetValue("z_items_price");

		// type_price
		$transaction->type_price->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_type_price"));
		$transaction->type_price->AdvancedSearch->SearchOperator = $objForm->GetValue("z_type_price");

		// shipping_address_id
		$transaction->shipping_address_id->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_shipping_address_id"));
		$transaction->shipping_address_id->AdvancedSearch->SearchOperator = $objForm->GetValue("z_shipping_address_id");

		// appcode
		$transaction->appcode->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_appcode"));
		$transaction->appcode->AdvancedSearch->SearchOperator = $objForm->GetValue("z_appcode");

		// tranid
		$transaction->tranid->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_tranid"));
		$transaction->tranid->AdvancedSearch->SearchOperator = $objForm->GetValue("z_tranid");

		// status_nbepay
		$transaction->status_nbepay->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_status_nbepay"));
		$transaction->status_nbepay->AdvancedSearch->SearchOperator = $objForm->GetValue("z_status_nbepay");

		// paydate
		$transaction->paydate->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_paydate"));
		$transaction->paydate->AdvancedSearch->SearchOperator = $objForm->GetValue("z_paydate");
		$transaction->paydate->AdvancedSearch->SearchCondition = $objForm->GetValue("v_paydate");
		$transaction->paydate->AdvancedSearch->SearchValue2 = ew_StripSlashes($objForm->GetValue("y_paydate"));
		$transaction->paydate->AdvancedSearch->SearchOperator2 = $objForm->GetValue("w_paydate");

		// isInvalid
		$transaction->isInvalid->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_isInvalid"));
		$transaction->isInvalid->AdvancedSearch->SearchOperator = $objForm->GetValue("z_isInvalid");

		// remarks
		$transaction->remarks->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_remarks"));
		$transaction->remarks->AdvancedSearch->SearchOperator = $objForm->GetValue("z_remarks");

		// consignment_no
		$transaction->consignment_no->AdvancedSearch->SearchValue = ew_StripSlashes($objForm->GetValue("x_consignment_no"));
		$transaction->consignment_no->AdvancedSearch->SearchOperator = $objForm->GetValue("z_consignment_no");
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language, $transaction;

		// Initialize URLs
		// Call Row_Rendering event

		$transaction->Row_Rendering();

		// Common render codes for all row types
		// id
		// order_no
		// user_id
		// amount
		// status_payment
		// status_transaction
		// total_item
		// total_weight
		// postage_price
		// items_price
		// type_price
		// shipping_address_id
		// appcode
		// tranid
		// domain
		// status_nbepay
		// currency
		// paydate
		// channel
		// serialkey
		// vcode
		// modified_date
		// created_date
		// isInvalid
		// remarks
		// consignment_no

		if ($transaction->RowType == EW_ROWTYPE_VIEW) { // View row

			// id
			$transaction->id->ViewValue = $transaction->id->CurrentValue;
			$transaction->id->ViewCustomAttributes = "";

			// order_no
			$transaction->order_no->ViewValue = $transaction->order_no->CurrentValue;
			$transaction->order_no->ViewCustomAttributes = "";

			// user_id
			$transaction->user_id->ViewValue = $transaction->user_id->CurrentValue;
			if (strval($transaction->user_id->CurrentValue) <> "") {
				$sFilterWrk = "`id` = " . ew_AdjustSql($transaction->user_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `username`, `name`, `no_ahli` FROM `user`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$transaction->user_id->ViewValue = $rswrk->fields('username');
					$transaction->user_id->ViewValue .= ew_ValueSeparator(0,1,$transaction->user_id) . $rswrk->fields('name');
					$transaction->user_id->ViewValue .= ew_ValueSeparator(0,2,$transaction->user_id) . $rswrk->fields('no_ahli');
					$rswrk->Close();
				} else {
					$transaction->user_id->ViewValue = $transaction->user_id->CurrentValue;
				}
			} else {
				$transaction->user_id->ViewValue = NULL;
			}
			$transaction->user_id->ViewCustomAttributes = "";

			// amount
			$transaction->amount->ViewValue = $transaction->amount->CurrentValue;
			$transaction->amount->ViewCustomAttributes = "";

			// status_payment
			$transaction->status_payment->ViewValue = $transaction->status_payment->CurrentValue;
			$transaction->status_payment->ViewCustomAttributes = "";

			// status_transaction
			if (strval($transaction->status_transaction->CurrentValue) <> "") {
				switch ($transaction->status_transaction->CurrentValue) {
					case "Waiting from admin action":
						$transaction->status_transaction->ViewValue = $transaction->status_transaction->FldTagCaption(1) <> "" ? $transaction->status_transaction->FldTagCaption(1) : $transaction->status_transaction->CurrentValue;
						break;
					case "Admin has confirmed products have delivered to a courier":
						$transaction->status_transaction->ViewValue = $transaction->status_transaction->FldTagCaption(2) <> "" ? $transaction->status_transaction->FldTagCaption(2) : $transaction->status_transaction->CurrentValue;
						break;
					case "Admin has confirmed products have received by customer":
						$transaction->status_transaction->ViewValue = $transaction->status_transaction->FldTagCaption(3) <> "" ? $transaction->status_transaction->FldTagCaption(3) : $transaction->status_transaction->CurrentValue;
						break;
					default:
						$transaction->status_transaction->ViewValue = $transaction->status_transaction->CurrentValue;
				}
			} else {
				$transaction->status_transaction->ViewValue = NULL;
			}
			$transaction->status_transaction->ViewCustomAttributes = "";

			// total_item
			$transaction->total_item->ViewValue = $transaction->total_item->CurrentValue;
			$transaction->total_item->ViewCustomAttributes = "";

			// total_weight
			$transaction->total_weight->ViewValue = $transaction->total_weight->CurrentValue;
			$transaction->total_weight->ViewCustomAttributes = "";

			// postage_price
			$transaction->postage_price->ViewValue = $transaction->postage_price->CurrentValue;
			$transaction->postage_price->ViewCustomAttributes = "";

			// items_price
			$transaction->items_price->ViewValue = $transaction->items_price->CurrentValue;
			$transaction->items_price->ViewCustomAttributes = "";

			// type_price
			if (strval($transaction->type_price->CurrentValue) <> "") {
				switch ($transaction->type_price->CurrentValue) {
					case "Harga Biasa":
						$transaction->type_price->ViewValue = $transaction->type_price->FldTagCaption(1) <> "" ? $transaction->type_price->FldTagCaption(1) : $transaction->type_price->CurrentValue;
						break;
					case "Harga Untuk Keahlian Ana Edar":
						$transaction->type_price->ViewValue = $transaction->type_price->FldTagCaption(2) <> "" ? $transaction->type_price->FldTagCaption(2) : $transaction->type_price->CurrentValue;
						break;
					default:
						$transaction->type_price->ViewValue = $transaction->type_price->CurrentValue;
				}
			} else {
				$transaction->type_price->ViewValue = NULL;
			}
			$transaction->type_price->ViewCustomAttributes = "";

			// shipping_address_id
			$transaction->shipping_address_id->ViewValue = $transaction->shipping_address_id->CurrentValue;
			if (strval($transaction->shipping_address_id->CurrentValue) <> "") {
				$sFilterWrk = "`id` = " . ew_AdjustSql($transaction->shipping_address_id->CurrentValue) . "";
			$sSqlWrk = "SELECT `address`, `poskod`, `city` FROM `address`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$transaction->shipping_address_id->ViewValue = $rswrk->fields('address');
					$transaction->shipping_address_id->ViewValue .= ew_ValueSeparator(0,1,$transaction->shipping_address_id) . $rswrk->fields('poskod');
					$transaction->shipping_address_id->ViewValue .= ew_ValueSeparator(0,2,$transaction->shipping_address_id) . $rswrk->fields('city');
					$rswrk->Close();
				} else {
					$transaction->shipping_address_id->ViewValue = $transaction->shipping_address_id->CurrentValue;
				}
			} else {
				$transaction->shipping_address_id->ViewValue = NULL;
			}
			$transaction->shipping_address_id->ViewCustomAttributes = "";

			// appcode
			$transaction->appcode->ViewValue = $transaction->appcode->CurrentValue;
			$transaction->appcode->ViewCustomAttributes = "";

			// tranid
			$transaction->tranid->ViewValue = $transaction->tranid->CurrentValue;
			$transaction->tranid->ViewCustomAttributes = "";

			// status_nbepay
			$transaction->status_nbepay->ViewValue = $transaction->status_nbepay->CurrentValue;
			$transaction->status_nbepay->ViewCustomAttributes = "";

			// paydate
			$transaction->paydate->ViewValue = $transaction->paydate->CurrentValue;
			$transaction->paydate->ViewValue = ew_FormatDateTime($transaction->paydate->ViewValue, 7);
			$transaction->paydate->ViewCustomAttributes = "";

			// modified_date
			$transaction->modified_date->ViewValue = $transaction->modified_date->CurrentValue;
			$transaction->modified_date->ViewValue = ew_FormatDateTime($transaction->modified_date->ViewValue, 11);
			$transaction->modified_date->ViewCustomAttributes = "";

			// created_date
			$transaction->created_date->ViewValue = $transaction->created_date->CurrentValue;
			$transaction->created_date->ViewValue = ew_FormatDateTime($transaction->created_date->ViewValue, 11);
			$transaction->created_date->ViewCustomAttributes = "";

			// isInvalid
			if (strval($transaction->isInvalid->CurrentValue) <> "") {
				switch ($transaction->isInvalid->CurrentValue) {
					case "0":
						$transaction->isInvalid->ViewValue = $transaction->isInvalid->FldTagCaption(1) <> "" ? $transaction->isInvalid->FldTagCaption(1) : $transaction->isInvalid->CurrentValue;
						break;
					case "1":
						$transaction->isInvalid->ViewValue = $transaction->isInvalid->FldTagCaption(2) <> "" ? $transaction->isInvalid->FldTagCaption(2) : $transaction->isInvalid->CurrentValue;
						break;
					default:
						$transaction->isInvalid->ViewValue = $transaction->isInvalid->CurrentValue;
				}
			} else {
				$transaction->isInvalid->ViewValue = NULL;
			}
			$transaction->isInvalid->ViewCustomAttributes = "";

			// remarks
			$transaction->remarks->ViewValue = $transaction->remarks->CurrentValue;
			$transaction->remarks->ViewCustomAttributes = "";

			// consignment_no
			$transaction->consignment_no->ViewValue = $transaction->consignment_no->CurrentValue;
			$transaction->consignment_no->ViewCustomAttributes = "";

			// id
			$transaction->id->LinkCustomAttributes = "";
			$transaction->id->HrefValue = "";
			$transaction->id->TooltipValue = "";

			// order_no
			$transaction->order_no->LinkCustomAttributes = "";
			$transaction->order_no->HrefValue = "";
			$transaction->order_no->TooltipValue = "";

			// user_id
			$transaction->user_id->LinkCustomAttributes = "";
			$transaction->user_id->HrefValue = "";
			$transaction->user_id->TooltipValue = "";

			// amount
			$transaction->amount->LinkCustomAttributes = "";
			$transaction->amount->HrefValue = "";
			$transaction->amount->TooltipValue = "";

			// status_payment
			$transaction->status_payment->LinkCustomAttributes = "";
			$transaction->status_payment->HrefValue = "";
			$transaction->status_payment->TooltipValue = "";

			// status_transaction
			$transaction->status_transaction->LinkCustomAttributes = "";
			$transaction->status_transaction->HrefValue = "";
			$transaction->status_transaction->TooltipValue = "";

			// total_item
			$transaction->total_item->LinkCustomAttributes = "";
			$transaction->total_item->HrefValue = "";
			$transaction->total_item->TooltipValue = "";

			// total_weight
			$transaction->total_weight->LinkCustomAttributes = "";
			$transaction->total_weight->HrefValue = "";
			$transaction->total_weight->TooltipValue = "";

			// postage_price
			$transaction->postage_price->LinkCustomAttributes = "";
			$transaction->postage_price->HrefValue = "";
			$transaction->postage_price->TooltipValue = "";

			// items_price
			$transaction->items_price->LinkCustomAttributes = "";
			$transaction->items_price->HrefValue = "";
			$transaction->items_price->TooltipValue = "";

			// type_price
			$transaction->type_price->LinkCustomAttributes = "";
			$transaction->type_price->HrefValue = "";
			$transaction->type_price->TooltipValue = "";

			// shipping_address_id
			$transaction->shipping_address_id->LinkCustomAttributes = "";
			$transaction->shipping_address_id->HrefValue = "";
			$transaction->shipping_address_id->TooltipValue = "";

			// appcode
			$transaction->appcode->LinkCustomAttributes = "";
			$transaction->appcode->HrefValue = "";
			$transaction->appcode->TooltipValue = "";

			// tranid
			$transaction->tranid->LinkCustomAttributes = "";
			$transaction->tranid->HrefValue = "";
			$transaction->tranid->TooltipValue = "";

			// status_nbepay
			$transaction->status_nbepay->LinkCustomAttributes = "";
			$transaction->status_nbepay->HrefValue = "";
			$transaction->status_nbepay->TooltipValue = "";

			// paydate
			$transaction->paydate->LinkCustomAttributes = "";
			$transaction->paydate->HrefValue = "";
			$transaction->paydate->TooltipValue = "";

			// isInvalid
			$transaction->isInvalid->LinkCustomAttributes = "";
			$transaction->isInvalid->HrefValue = "";
			$transaction->isInvalid->TooltipValue = "";

			// remarks
			$transaction->remarks->LinkCustomAttributes = "";
			$transaction->remarks->HrefValue = "";
			$transaction->remarks->TooltipValue = "";

			// consignment_no
			$transaction->consignment_no->LinkCustomAttributes = "";
			$transaction->consignment_no->HrefValue = "";
			$transaction->consignment_no->TooltipValue = "";
		} elseif ($transaction->RowType == EW_ROWTYPE_SEARCH) { // Search row

			// id
			$transaction->id->EditCustomAttributes = "";
			$transaction->id->EditValue = ew_HtmlEncode($transaction->id->AdvancedSearch->SearchValue);

			// order_no
			$transaction->order_no->EditCustomAttributes = "";
			$transaction->order_no->EditValue = ew_HtmlEncode($transaction->order_no->AdvancedSearch->SearchValue);

			// user_id
			$transaction->user_id->EditCustomAttributes = "";
			$transaction->user_id->EditValue = ew_HtmlEncode($transaction->user_id->AdvancedSearch->SearchValue);
			if (strval($transaction->user_id->AdvancedSearch->SearchValue) <> "") {
				$sFilterWrk = "`id` = " . ew_AdjustSql($transaction->user_id->AdvancedSearch->SearchValue) . "";
			$sSqlWrk = "SELECT `username`, `name`, `no_ahli` FROM `user`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$transaction->user_id->EditValue = $rswrk->fields('username');
					$transaction->user_id->EditValue .= ew_ValueSeparator(0,1,$transaction->user_id) . $rswrk->fields('name');
					$transaction->user_id->EditValue .= ew_ValueSeparator(0,2,$transaction->user_id) . $rswrk->fields('no_ahli');
					$rswrk->Close();
				} else {
					$transaction->user_id->EditValue = $transaction->user_id->AdvancedSearch->SearchValue;
				}
			} else {
				$transaction->user_id->EditValue = NULL;
			}

			// amount
			$transaction->amount->EditCustomAttributes = "";
			$transaction->amount->EditValue = ew_HtmlEncode($transaction->amount->AdvancedSearch->SearchValue);

			// status_payment
			$transaction->status_payment->EditCustomAttributes = "";
			$transaction->status_payment->EditValue = ew_HtmlEncode($transaction->status_payment->AdvancedSearch->SearchValue);

			// status_transaction
			$transaction->status_transaction->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("Waiting from admin action", $transaction->status_transaction->FldTagCaption(1) <> "" ? $transaction->status_transaction->FldTagCaption(1) : "Waiting from admin action");
			$arwrk[] = array("Admin has confirmed products have delivered to a courier", $transaction->status_transaction->FldTagCaption(2) <> "" ? $transaction->status_transaction->FldTagCaption(2) : "Admin has confirmed products have delivered to a courier");
			$arwrk[] = array("Admin has confirmed products have received by customer", $transaction->status_transaction->FldTagCaption(3) <> "" ? $transaction->status_transaction->FldTagCaption(3) : "Admin has confirmed products have received by customer");
			$transaction->status_transaction->EditValue = $arwrk;

			// total_item
			$transaction->total_item->EditCustomAttributes = "";
			$transaction->total_item->EditValue = ew_HtmlEncode($transaction->total_item->AdvancedSearch->SearchValue);

			// total_weight
			$transaction->total_weight->EditCustomAttributes = "";
			$transaction->total_weight->EditValue = ew_HtmlEncode($transaction->total_weight->AdvancedSearch->SearchValue);

			// postage_price
			$transaction->postage_price->EditCustomAttributes = "";
			$transaction->postage_price->EditValue = ew_HtmlEncode($transaction->postage_price->AdvancedSearch->SearchValue);

			// items_price
			$transaction->items_price->EditCustomAttributes = "";
			$transaction->items_price->EditValue = ew_HtmlEncode($transaction->items_price->AdvancedSearch->SearchValue);

			// type_price
			$transaction->type_price->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("Harga Biasa", $transaction->type_price->FldTagCaption(1) <> "" ? $transaction->type_price->FldTagCaption(1) : "Harga Biasa");
			$arwrk[] = array("Harga Untuk Keahlian Ana Edar", $transaction->type_price->FldTagCaption(2) <> "" ? $transaction->type_price->FldTagCaption(2) : "Harga Untuk Keahlian Ana Edar");
			$transaction->type_price->EditValue = $arwrk;

			// shipping_address_id
			$transaction->shipping_address_id->EditCustomAttributes = "";
			$transaction->shipping_address_id->EditValue = ew_HtmlEncode($transaction->shipping_address_id->AdvancedSearch->SearchValue);
			if (strval($transaction->shipping_address_id->AdvancedSearch->SearchValue) <> "") {
				$sFilterWrk = "`id` = " . ew_AdjustSql($transaction->shipping_address_id->AdvancedSearch->SearchValue) . "";
			$sSqlWrk = "SELECT `address`, `poskod`, `city` FROM `address`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$transaction->shipping_address_id->EditValue = $rswrk->fields('address');
					$transaction->shipping_address_id->EditValue .= ew_ValueSeparator(0,1,$transaction->shipping_address_id) . $rswrk->fields('poskod');
					$transaction->shipping_address_id->EditValue .= ew_ValueSeparator(0,2,$transaction->shipping_address_id) . $rswrk->fields('city');
					$rswrk->Close();
				} else {
					$transaction->shipping_address_id->EditValue = $transaction->shipping_address_id->AdvancedSearch->SearchValue;
				}
			} else {
				$transaction->shipping_address_id->EditValue = NULL;
			}

			// appcode
			$transaction->appcode->EditCustomAttributes = "";
			$transaction->appcode->EditValue = ew_HtmlEncode($transaction->appcode->AdvancedSearch->SearchValue);

			// tranid
			$transaction->tranid->EditCustomAttributes = "";
			$transaction->tranid->EditValue = ew_HtmlEncode($transaction->tranid->AdvancedSearch->SearchValue);

			// status_nbepay
			$transaction->status_nbepay->EditCustomAttributes = "";
			$transaction->status_nbepay->EditValue = ew_HtmlEncode($transaction->status_nbepay->AdvancedSearch->SearchValue);

			// paydate
			$transaction->paydate->EditCustomAttributes = "";
			$transaction->paydate->EditValue = ew_HtmlEncode(ew_FormatDateTime(ew_UnFormatDateTime($transaction->paydate->AdvancedSearch->SearchValue, 7), 7));
			$transaction->paydate->EditCustomAttributes = "";
			$transaction->paydate->EditValue2 = ew_HtmlEncode(ew_FormatDateTime(ew_UnFormatDateTime($transaction->paydate->AdvancedSearch->SearchValue2, 7), 7));

			// isInvalid
			$transaction->isInvalid->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("0", $transaction->isInvalid->FldTagCaption(1) <> "" ? $transaction->isInvalid->FldTagCaption(1) : "0");
			$arwrk[] = array("1", $transaction->isInvalid->FldTagCaption(2) <> "" ? $transaction->isInvalid->FldTagCaption(2) : "1");
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$transaction->isInvalid->EditValue = $arwrk;

			// remarks
			$transaction->remarks->EditCustomAttributes = "";
			$transaction->remarks->EditValue = ew_HtmlEncode($transaction->remarks->AdvancedSearch->SearchValue);

			// consignment_no
			$transaction->consignment_no->EditCustomAttributes = "";
			$transaction->consignment_no->EditValue = ew_HtmlEncode($transaction->consignment_no->AdvancedSearch->SearchValue);
		}
		if ($transaction->RowType == EW_ROWTYPE_ADD ||
			$transaction->RowType == EW_ROWTYPE_EDIT ||
			$transaction->RowType == EW_ROWTYPE_SEARCH) { // Add / Edit / Search row
			$transaction->SetupFieldTitles();
		}

		// Call Row Rendered event
		if ($transaction->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$transaction->Row_Rendered();
	}

	// Validate search
	function ValidateSearch() {
		global $gsSearchError, $transaction;

		// Initialize
		$gsSearchError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return TRUE;
		if (!ew_CheckInteger($transaction->id->AdvancedSearch->SearchValue)) {
			ew_AddMessage($gsSearchError, $transaction->id->FldErrMsg());
		}
		if (!ew_CheckInteger($transaction->user_id->AdvancedSearch->SearchValue)) {
			ew_AddMessage($gsSearchError, $transaction->user_id->FldErrMsg());
		}
		if (!ew_CheckNumber($transaction->amount->AdvancedSearch->SearchValue)) {
			ew_AddMessage($gsSearchError, $transaction->amount->FldErrMsg());
		}
		if (!ew_CheckNumber($transaction->total_item->AdvancedSearch->SearchValue)) {
			ew_AddMessage($gsSearchError, $transaction->total_item->FldErrMsg());
		}
		if (!ew_CheckNumber($transaction->total_weight->AdvancedSearch->SearchValue)) {
			ew_AddMessage($gsSearchError, $transaction->total_weight->FldErrMsg());
		}
		if (!ew_CheckNumber($transaction->postage_price->AdvancedSearch->SearchValue)) {
			ew_AddMessage($gsSearchError, $transaction->postage_price->FldErrMsg());
		}
		if (!ew_CheckNumber($transaction->items_price->AdvancedSearch->SearchValue)) {
			ew_AddMessage($gsSearchError, $transaction->items_price->FldErrMsg());
		}
		if (!ew_CheckInteger($transaction->shipping_address_id->AdvancedSearch->SearchValue)) {
			ew_AddMessage($gsSearchError, $transaction->shipping_address_id->FldErrMsg());
		}
		if (!ew_CheckEuroDate($transaction->paydate->AdvancedSearch->SearchValue)) {
			ew_AddMessage($gsSearchError, $transaction->paydate->FldErrMsg());
		}
		if (!ew_CheckEuroDate($transaction->paydate->AdvancedSearch->SearchValue2)) {
			ew_AddMessage($gsSearchError, $transaction->paydate->FldErrMsg());
		}

		// Return validate result
		$ValidateSearch = ($gsSearchError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateSearch = $ValidateSearch && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			ew_AddMessage($gsSearchError, $sFormCustomError);
		}
		return $ValidateSearch;
	}

	// Load advanced search
	function LoadAdvancedSearch() {
		global $transaction;
		$transaction->id->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_id");
		$transaction->order_no->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_order_no");
		$transaction->user_id->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_user_id");
		$transaction->amount->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_amount");
		$transaction->status_payment->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_status_payment");
		$transaction->status_transaction->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_status_transaction");
		$transaction->total_item->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_total_item");
		$transaction->total_weight->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_total_weight");
		$transaction->postage_price->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_postage_price");
		$transaction->items_price->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_items_price");
		$transaction->type_price->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_type_price");
		$transaction->shipping_address_id->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_shipping_address_id");
		$transaction->appcode->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_appcode");
		$transaction->tranid->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_tranid");
		$transaction->status_nbepay->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_status_nbepay");
		$transaction->paydate->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_paydate");
		$transaction->paydate->AdvancedSearch->SearchValue2 = $transaction->getAdvancedSearch("y_paydate");
		$transaction->isInvalid->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_isInvalid");
		$transaction->remarks->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_remarks");
		$transaction->consignment_no->AdvancedSearch->SearchValue = $transaction->getAdvancedSearch("x_consignment_no");
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	// $type = ''|'success'|'failure'
	function Message_Showing(&$msg, $type) {

		// Example:
		//if ($type == 'success') $msg = "your success message";

	}

	// Page Data Rendering event
	function Page_DataRendering(&$header) {

		// Example:
		//$header = "your header";

	}

	// Page Data Rendered event
	function Page_DataRendered(&$footer) {

		// Example:
		//$footer = "your footer";

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}
}
?>
